package com.lib.common.base.web.bridge

import android.webkit.JavascriptInterface
import wendu.dsbridge.CompletionHandler


/**
 * Copyright (C), 2019-2020
 * FileName: NativeBridge
 * Author: Kevin
 * Date: 2020-01-15 10:54
 * Description: js 主动调用 原生的 桥接
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
class JsToNativeBridge(private val jsToNativeBridgeMethodHelper: JsToNativeBridgeMethodHelper) {

    //同步API
    @JavascriptInterface
    fun testSyn(msg: Any): String? {
        return "$msg［syn call］"
    }

    //异步API
    @JavascriptInterface
    fun testAsyn(msg: Any, handler: CompletionHandler<String?>) {
        jsToNativeBridgeMethodHelper.callMethod(msg, handler)
    }
}